package com.ll.daipao.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * Created by rockyll on 2017/10/13.
 */
public class BaseController {
    protected Logger logger = LoggerFactory.getLogger(this.getClass());


    public String success(){
        return handle(true,"成功",null);
    }


    public String success(Object object){
        return handle(true,"成功",object);
    }

    public String success(String msg , Object object){
        return handle(true,"成功",object);
    }


    public String failed(){
        return handle(false,"失败",null);
    }

    public String failed(String msg){
        return handle(false,msg,null);
    }

    public String failed(String msg , Object o){
        return handle(false,msg,o);
    }


    public  String handle(Boolean suc , String msg,Object data){
        JSONObject.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
        JSONObject res = new JSONObject();
        res.put("suc",suc);
        res.put("msg", msg);
        res.put("data",data);
        return JSON.toJSONStringWithDateFormat(res,"yyyy-MM-dd HH:mm");
    }


}
